
const {ccclass, property} = cc._decorator;

@ccclass
export default class BaseComponent extends cc.Component {


    private ui_views:any = [];
    onLoad () 
    {
        this.ui_views = {};
        this.load_all_object(this.node,"");


    }

   load_all_object(root, path) 
    {
        for(let i = 0; i < root.childrenCount; i ++) 
        {
            this.ui_views[path + root.children[i].name] = root.children[i];
            this.load_all_object(root.children[i], path + root.children[i].name + "/");
        }
    }

    add_button_listen(view_name, caller, func) 
    {
        var view_node = this.ui_views[view_name];
        if (!view_node) 
        {
            return;
        }
        var button = view_node.getComponent(cc.Button);
        if (!button) 
        {
            return;
        }
        view_node.on("click", func, caller);
    }

    start () 
    {

    }

    // update (dt) {}
}
